/**
 * 订单相关相关接口
 */
import request from '@/utils/request'

export default {
  /** addOrder.vue---开始 **/
  /** 初始化订单提交页面的商品信息 **/
  addOrderInfosByShopCart(params){
    let data = params;
    return request({
      url: '/shopCart/infosAndOrder',
      method: 'post',
      data
    })
  },
  /** 购物车提交订单信息 **/
  submitOrderByCart(carts, price, address, postscript){
    let data = {
      goods: carts,
      price: price,
      address: address,
      postscript: postscript,
      addType: 'cart'
    }
    return request({
      url: '/shopOrderInfo/addInfo',
      method: 'post',
      data
    })
  },
  payVerification(params){
    let data = {
      orderId: params.orderId,
      orderSn: params.orderSn,
    }
    return request({
      url: '/shopOrderInfo/payVerification',
      method: 'post',
      data
    })
  },
  /** 订单支付 **/
  payOrder(carts){
    let data = {
      id: carts.id,
      orderStatus: carts.orderStatus
    }
    return request({
      url: '/shopOrderInfo/payOrReceive',
      method: 'post',
      data
    })
  },
  /** addOrder.vue---结束 **/
  /** allOrderInfo.vue---开始 **/
  initAllOrderInfo(params){
    let data = {
      orderStatusList: params.orderStatusList,
    }
    return request({
      url: '/shopOrderInfo/listByPage?size='+params.pagesize+'&page='+params.currentPage,
      method: 'post',
      data
    })
  },
  /** allOrderInfo.vue---结束 **/
  /** returnOperation.vue---开始 **/
  saveOrderReturnInfo(params){
    let data = {
      returnNote: params.returnNote,
      orderId: params.orderId,
    }
    return request({
      url: '/shopOrderReturn/save',
      method: 'post',
      data
    })
  },
  /** returnOperation.vue---结束 **/
  /** 公共功能 **/
  /** 商品确认收到 **/
  receiveGoods(goods){
    let data = {
      id: goods.id,
      orderStatus: goods.orderStatus
    }
    return request({
      url: '/shopOrderInfo/data/updateById',
      method: 'post',
      data
    })
  },
  /** 获取订单详细信息 **/
  getOrderInfoById(params){
    let data = {
      id:params.orderId
    }
    return request({
      url: '/shopOrderInfo/infoById',
      method: 'post',
      data
    })
  },
  /** 删除订单信息，实际是修改字段 **/
  deleteOrderInfoById(params){
    let data = {
      id:params.orderId,
      delFlag:1
    }
    return request({
      url: '/shopOrderInfo/data/updateById',
      method: 'post',
      data
    })
  },
  /** 订单详情组件-orderInfoDialog.vue---开始 **/
  getOrderReturnInfoByOrderId(params){
    let data = {
      orderId:params.orderId
    }
    return request({
      url: '/shopOrderReturn/data/info',
      method: 'post',
      data
    })
  },
  /** 订单详情组件-orderInfoDialog.vue---结束 **/
  /** 订单商品评论 **/
  orderGoodsComment(params){
    let data = {
      orderId: params.orderId,
      goodsId: params.goodsId,
      orderGoodsId: params.orderGoodsId,
      productsId: params.productsId,
      productsName: params.productsName,
      points: params.points,
      content: params.content,
    }
    return request({
      url: '/shopGoodsComment/submit',
      method: 'post',
      data
    })
  },
  /** orderPay.vue -- 开始 **/
  orderPay(params){
    let data = {
      orderSn: params.orderSn,
      amount: params.amount.toString(),
    }
    return request({
      url: '/shopOrderInfo/payByZhiFuBao',
      method: 'post',
      data
    })
  },
  /** orderPay.vue -- 结束 **/
  /** zhiFuBaoSuccRet.vue -- 开始 **/
  orderPaySucc(params){
      let data = {
        orderSn:  params.orderSn,
        payTime:  params.payTime,
        orderStatus:30
      }
    return request({
      url: '/shopOrderInfo/pay',
      method: 'post',
      data
    })
  }
  /** zhiFuBaoSuccRet.vue -- 结束 **/
}
